<?php
// UserModel.php
class UserModel {
    private $db;

    public function __construct($dbConnection) {
        $this->db = $dbConnection;
    }

	public function validateUser($username, $password) {
		$password = md5($password);
		if ($stmt = $this->db->prepare("SELECT * FROM post_users WHERE u_name = ? AND u_pwd = ?")) {
			$stmt->bind_param("ss", $username, $password);
			$stmt->execute();
			$result = $stmt->get_result();
			return $result->num_rows > 0;
		} else {
			// Prepare failed: print error info and exit or throw an exception
			error_log("Prepare failed: " . $this->db->error);
			// For example, throw an exception
			throw new Exception("Database prepare error: " . $this->db->error);
		}
	}
}
?>
